﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace DMS.Business.WebControls
{
    public class YiduListBox : ListBox
    {
        public void SetListValue(string listValue)
        {
            if (listValue == null || listValue.Trim() == string.Empty)
                return;
            string[] valueList = listValue.Split(new char[] {','});
            if (valueList.Length == 0)
                return;
            for (int i = 0; i < valueList.Length; i++)
            {
                if (valueList[i].Length != 0 && valueList[i] != string.Empty)
                    this.Items.FindByValue(valueList[i]).Selected = true;
            }
        }

        public string GetListValue()
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < this.Items.Count; i++)
            {
                if (this.Items[i].Selected)
                    sb.Append(this.Items[i].Value + ",");
            }
            return sb.Remove(sb.Length - 1, 1).ToString();
        }
    }

}
